using System;
using GameStateManagement;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;

namespace Life
{
    public class SaveScreen : SingleControlScreen
    {
        private InputAction pauseAction;

        public SaveScreen()
        {
            pauseAction = new InputAction(
                new Buttons[] { Buttons.Start, Buttons.Back },
                new Keys[] { Keys.Escape },
                true);

            // We need tap gestures to hit the buttons
            EnabledGestures = GestureType.Tap | GestureType.Hold;
        }

        public override void LoadContent()
        {
            EnabledGestures |= ScrollTracker.GesturesNeeded;
            
            RootControl = new SavePanel(ScreenManager, true, 20);
            base.LoadContent();
        }

        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");


            PlayerIndex player;
            if (pauseAction.Evaluate(input, ControllingPlayer, out player))
            {
                LoadingScreen.Load(ScreenManager, false, player, new GameplayScreen());
            }

            base.HandleInput(gameTime, input);
        }
    }
}
